#include once "fbgfx.bi"

'*********************** CONSTANT ************************

Const MAP_HEADER = "W:BM_MAP" 'Header for map files

Const As UInteger TILE_SIZE = 48

Const as integer _
MAP_MAX_Y = 63, _ 'Maximum height of tiles
MAP_MAX_X = 63    'Maximum width of tiles

const map_x = 528 '\ 12 x 10 tiles
const map_y = 480 '/   

'**********************   ENUM   *************************

/'
   This enum is for loading map files
   The first integer will be one of these
   describing what it is, then next will be
   another integer for size in bytes, then the data
'/
enum ENUM_MAP_DESCRIPTOR 'integer
MAP_NAME
MAP_DESCRIPTION
MAP_DATA
MAP_NUM_HEROES
MAP_TILES_GFX
End Enum

'0 is void, 1-64 passable, 65-128 destructible, 129-192 blockers, rest reserved
enum ENUM_MAP_TILES 'byte
TILE_VOID = 0
'------------------
TILE_FLOOR = 1
TILE_TELEPORT
'------------------
TILE_BRICK = 65
'------------------
TILE_BOUNDARY = 129
TILE_STEEL
End Enum

/' Extended descriptors for MAP_DATA
   These will follow the ENUM_MAP_TILES in MAP_DATA
   ex:
      W:BM_MAP   00000002     00000008     02               01                 13 09  FFFF      00
      HEADER     MAP_DATA     Size:8Bytes  TILE_TELEPORT    MAP_DATA_TELEPORT  X  Y   Reserved  MAP_DATA_NULL
'/
enum ENUM_MAP_DATA_DESCRIPTOR 'byte
MAP_DATA_NULL = 0 'No more extended data, move onto next block
MAP_DATA_TELEPORT
MAP_DATA_SWITCH
MAP_DATA_RESERVED = &HFF
End Enum


enum ENUM_MAP_ERROR 'integer
MAP_ERROR_BAD_HEADER = 1000
MAP_ERROR_INVALID
End Enum




'**********************   TYPE   ************************

type map_block
   as ushort id  ' enum ENUM_MAP_TILES

   'Co-ordinates
   as ubyte gp_y
   as ubyte gp_x

   'Boolean Values
   as ubyte gp_disabled : 1
   as ubyte gp_invisible : 1

End Type

type map

   as map_block ptr ptr grid
   as uinteger max_x
   as uinteger max_y

   As UInteger default_heroes

   As String Name
   As String desc

   as fb.image ptr tiles(256)

end Type

Declare function loadMap(file as string, byref ret_map as map) as integer
Declare sub unloadMap(byref curr_map as map)
Declare sub drawMap(camx as integer, camy as integer)
